package com.example.train_operate.controller;

import com.example.train_operate.entity.Inspection;
import com.example.train_operate.service.DailyInspectionJudgmentService;
import com.example.train_operate.util.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@Api(tags = "日常巡检指导书接口")
@RequestMapping("/DailyInspectionJudgment")
public class DailyInspectionJudgmentController {
    @Autowired
    private DailyInspectionJudgmentService dailyInspectionJudgmentService;
    @GetMapping("/getDailyInspectionJudgment")
    public Result getDailyInspectionJudgment(@RequestParam Integer step){
        Result result=dailyInspectionJudgmentService.getDailyInspectionJudgmentByStep(step);
        if(result.getData()==null) {
            return Result.fail().message("该步骤不存在");
        }
        System.out.println(result.getData());
        return dailyInspectionJudgmentService.getDailyInspectionJudgmentByStep(step);
    }
    @PostMapping("/addDailyInspectionJudgment")
    public Result addDailyInspectionJudgment(@RequestBody Inspection inspection){
        return dailyInspectionJudgmentService.addDailyInspectionJudgment(inspection);
    }
    @PutMapping("/updateDailyInspectionJudgment")
    public Result updateDailyInspectionJudgment(@RequestBody Inspection inspection){
        return dailyInspectionJudgmentService.updateDailyInspectionJudgment(inspection);
    }
    @DeleteMapping("/deleteDailyInspectionJudgment")
    public Result deleteDailyInspectionJudgment(@RequestParam Integer step){
        return dailyInspectionJudgmentService.deleteDailyInspectionJudgment( step);
    }

    @GetMapping("/listDailyInspectionJudgment")
    public Result listDailyInspectionJudgment(){
        return dailyInspectionJudgmentService.ListDailyInspectionJudgment();
    }
}
